from jinja2 import Template

tmpl = Template("""\
<html>
  <head><title>{{ title | escape }}</title></head>
  <body>
  {%- for item in items -%}
    {{ item }}{% if not loop.last %}, {% endif %}
  {%- endfor -%}
  </body>
</html>
""")

output = tmpl.render(title="输入 with <unsafe> data", items=[1, 2, 3, 4, 5, 6])

print(output)
